package com.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.beans.Msg;
import com.dao.MsgDao;

public class MsgDaoImpl extends UniversalDaoImpl implements MsgDao {

	public List getListMMsgByCenterXY(float x,float y,int zoom) {
		double r=Math.sqrt(x*x+y*y);
		String sql;
		sql="select * from m_msg ";//where power(lng-"+x+")+power(lat-"+y+")";
		logger.info(sql);
		return getJdbcTemplate().queryForList(sql);
	}
	public com.vo.Page list(int pageNo, int pageSize, Msg msg) {
		String sql="select m.id,userid,u.realname,companyid,co.cname companyName,c.name className,classcode,title,description,contact,m.tel,m.email,m.qq,website,inputdate,enddate,sessionid,tag,uptimes,downtimes,fix,m.views from j_msg m left join j_code c on m.classCode=c.code and c.type='ms' left join j_user u on u.id=m.userid left join j_company co on co.id=m.companyid where 1=1";
		Map param=new HashMap();
		if(msg.getClassCode()!=null&&!"".equals(msg.getClassCode()))param.put("classcode=?", msg.getClassCode());
		if(msg.getTitle()!=null&&!"".equals(msg.getTitle()))param.put("title like ?","%"+msg.getTitle()+"%");
		if(msg.getDescription()!=null&&!"".equals(msg.getDescription()))param.put("description like ?","%"+msg.getDescription()+"%");
		if(msg.getUserID()>0)param.put("userid=?", msg.getUserID());
		if(msg.getCompanyID()>0)param.put("companyid=?", msg.getCompanyID());
		return Page(pageNo, pageSize, sql,"inputdate", param);
	}
}